package BasicClassUse;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class IteratorUse {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("1");
        list.add("2");
        list.add("3");
        list.add("4");
        Iterator<String> it = list.iterator();
        while (it.hasNext()) {
            String obj = it.next();
            it.remove();
            System.out.println(obj);
        }
        System.out.println(list.size());
    }

}
